
#ifndef __TYPES_H
#define __TYPES_H
typedef unsigned int   uint_t;
typedef unsigned long  size_t;
typedef unsigned short ushort_t;
typedef unsigned char  uchar_t;
// typedef unsigned short wchar_t;
typedef long time_t;

typedef unsigned char  uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int   uint32_t;
typedef unsigned long  uint64_t;
typedef unsigned long  uintptr_t;
typedef int            int32_t;

#define NULL 0

#define readb(addr) (*(volatile uint8_t *)(addr))
#define readw(addr) (*(volatile uint16_t *)(addr))
#define readd(addr) (*(volatile uint32_t *)(addr))
#define readq(addr) (*(volatile uint64_t *)(addr))

#define writeb(v, addr)                                                        \
  {                                                                            \
    (*(volatile uint8_t *)(addr)) = (v);                                       \
  }
#define writew(v, addr)                                                        \
  {                                                                            \
    (*(volatile uint16_t *)(addr)) = (v);                                      \
  }
#define writed(v, addr)                                                        \
  {                                                                            \
    (*(volatile uint32_t *)(addr)) = (v);                                      \
  }
#define writeq(v, addr)                                                        \
  {                                                                            \
    (*(volatile uint64_t *)(addr)) = (v);                                      \
  }

#define NELEM(x) (sizeof(x) / sizeof((x)[0]))

#endif